


package com.UMLife.me.ui;

import com.UMLife.me.action.RegisterAction;
import com.UMLife.me.global.Global;
import de.enough.polish.ui.Choice;
import de.enough.polish.ui.ChoiceGroup;
import de.enough.polish.ui.ChoiceItem;
import de.enough.polish.ui.Container;
import de.enough.polish.ui.Form;
import de.enough.polish.ui.ImageItem;
import de.enough.polish.ui.Item;
import de.enough.polish.ui.StringItem;
import de.enough.polish.ui.TextField;





public class RegisterUI
		extends Form
{
	public RegisterUI()
	{
		//#style RegisterUI   
		super(null);
		//#style RegisterNameItem
		StringItem nameItem = new StringItem(null, "用户名：", Item.PLAIN);
		//#style RegisterNameItem
		StringItem mailItem = new StringItem(null, "邮箱：", Item.PLAIN);
		//#style RegisterNameItem
		StringItem phoneItem = new StringItem(null, "电话号码：", Item.PLAIN);
		//#style RegisterNameItem
		StringItem passwordItem = new StringItem(null, "密码：", Item.PLAIN);
		//#style RegisterNameItem
		StringItem passwordConfirmItem = new StringItem(null, "密码确认：",
				Item.PLAIN);
		//#style RegisterNameItem
		StringItem jobItem = new StringItem(null, "工作：", Item.PLAIN);
		//#style RegisterNameItem2
		StringItem sexStringItem = new StringItem(null, "性别：", Item.PLAIN);
		//#style RegisterNameItem2
		StringItem ageItem = new StringItem(null, "年龄：", Item.PLAIN);
		//#style RegisterNameItem2
		StringItem cityItem = new StringItem(null, "城市：", Item.PLAIN);
		
		//#style RegisterTextField
		this.name = new TextField(null, "", 15, TextField.ANY);
		//#style RegisterTextField
		this.mail = new TextField(null, "", 30, TextField.ANY);
		//#style RegisterTextField
		this.phone = new TextField(null, "", 11, TextField.DECIMAL);
		//#style RegisterTextField
		this.password = new TextField(null, "", 15, TextField.PASSWORD);
		//#style RegisterTextField
		this.pswConfirm = new TextField(null, "", 15, TextField.PASSWORD);
		//#style RegisterTextField
		this.city = new TextField(null, "", 15, TextField.ANY);
		//#style RegisterTextField
		this.age = new TextField(null, "", 15, TextField.DECIMAL);
		//#style RegisterTextField
		this.job = new TextField(null, "", 15, TextField.ANY);
		//#style RegisterChoiceGroup
		this.sex = new ChoiceGroup(null, Choice.POPUP);
		//#style sexItem
		ChoiceItem man = new ChoiceItem("男", null, Item.BUTTON);
		//#style sexItem
		ChoiceItem woman = new ChoiceItem("女", null, Item.BUTTON);
		this.sex.append(man);
		this.sex.append(woman);
		//#style RegisterCon
		Container con = new Container(true);
		//#style littleCon
		Container littleCon = new Container(true);
		littleCon.add(sexStringItem);
		littleCon.add(this.sex);
		littleCon.add(ageItem);
		littleCon.add(this.age);
		
		con.add(nameItem);
		con.add(this.name);
		con.add(mailItem);
		con.add(this.mail);
		con.add(phoneItem);
		con.add(this.phone);
		con.add(passwordItem);
		con.add(this.password);
		con.add(passwordConfirmItem);
		con.add(this.pswConfirm);
		con.add(jobItem);
		con.add(this.job);
		con.add(littleCon);
		
		this.append(Global.getGlobalLogo());
		this.append(con);
		
		RegisterAction action = new RegisterAction(this);
		this.setCommandListener(action);
		
	}
	
	public int getAge()
	{
		//TODO
		return Integer.parseInt(this.age.toString());
	}
	
	/**
	 * 获取城市
	 * 
	 * @return
	 */
	public String getCity()
	{
		//TODO
		return this.city.toString();
	}
	
	/**
	 * 获取职业
	 * 
	 * @return
	 */
	public String getJob()
	{
		//TODO
		return this.job.toString();
	}
	
	public String getName()
	{
		//TODO
		return this.name.toString();
	}
	
	/**
	 * 获取手机号码
	 * 
	 * @return
	 */
	public String getPhone()
	{
		//TODO
		return this.phone.toString();
	}
	
	public String getPsd()
	{
		return this.password.getString();
	}
	
	/**
	 * true表示男性，false表示女性，gay的不考虑
	 * 
	 * @return
	 */
	public boolean getSex()
	{
		if (this.sex.getSelectedIndex() == 0)
		{
			return true;
		}
		else
		{
			return false;
		}
		
	}
	
	private TextField	age;
	
	private TextField	city;
	
	private TextField	job;
	
	private ImageItem	logo;
	
	private TextField	mail;
	
	private TextField	name;
	
	private TextField	password;
	
	private TextField	phone;
	
	private TextField	pswConfirm;
	
	private ChoiceGroup	sex;		//会不会有gay
									
}
